import React from 'react'
import {Table} from 'antd'
import {connect} from 'react-redux'




const columns = [
  {
    title: '商品ID',
    dataIndex: 'goodId',
    key: 'id',
  },
  {
    title: '商品名称',
    dataIndex: 'goodName',
    key: 'name',
  },
  {
    title: '商品单价',
    dataIndex: 'goodPrice',
    key: 'price',
  },
  {
    title: '购买数量',
    dataIndex: 'goodNum',
    key: 'num',
  }
];
const rowSelection = {
  onChange: (selectedRowKeys, selectedRows) => {
    console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
  },
  getCheckboxProps: record => ({
    disabled: record.name === 'Disabled User', // Column configuration not to be checked
    name: record.name,
  }),
}
class Card extends React.PureComponent{
  render() {
    const {CardList} = this.props
    return (
      <div>
        <h2>购物车列表</h2>
        <hr/>
        <Table rowKey='goodId' rowSelection={rowSelection} columns={columns} dataSource={CardList} />
      </div>
    )
  }
}

export default connect(
  (state) => {
    return {
      CardList: state.CardList
    }
  },
  () => {
    return {}
  }
)(Card)